import Router from "@koa/router"
import { getAllMsgs, getMsg, createMsg, updateMsg, deleteMsg } from "../controllers/msgController.js"
import { getAllProjects, getProject, createProject, updateProject, deleteProject } from "../controllers/projectController.js"
import { getAllSkills, getSkill, createSkill, updateSkill, deleteSkill } from "../controllers/skillController.js"
import { getAllSentences, getSentence, createSentence, updateSentence, deleteSentence } from "../controllers/sentenceController.js"
import multer from "@koa/multer"

const router = new Router({ prefix: '/api' });
const upload = multer();

// 1 个人消息
router
  .get("/msgs", getAllMsgs)
  .get("/msg/:id", getMsg)
  .post("/msg", createMsg)
  .patch("/msg/:id", updateMsg)
  .delete("/msg/:id", deleteMsg)
// 2 个人技能
router
  .get("/skills", getAllSkills)
  .get("/skill/:id", getSkill)
  .post("/skill", createSkill)
  .patch("/skill/:id", updateSkill)
  .delete("/skill/:id", deleteSkill)
// 3 个人项目
router
  .get("/projects", getAllProjects)
  .get("/project/:id", getProject)
  .post("/project", upload.single("img"), createProject)
  .patch("/project/:id", upload.single(), updateProject)
  .delete("/project/:id", deleteProject)
// 4 打字机句子
router
  .get("/sentences", getAllSentences)
  .get("/sentence/:id", getSentence)
  .post("/sentence", createSentence)
  .patch("/sentence/:id", updateSentence)
  .delete("/sentence/:id", deleteSentence)
export default router
